<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>系统首页</title>
<!-- 下载并引入jquery easyUI -->
<link rel="stylesheet" type="text/css"
	href="../js/jquery-easyui-1.9.5/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="../js/jquery-easyui-1.9.5/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="../js/jquery-easyui-1.9.5/themes/color.css">
<script type="text/javascript"
	src="../js/jquery-easyui-1.9.5/jquery.min.js"></script>
<script type="text/javascript"
	src="../js/jquery-easyui-1.9.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/context-menu.js"></script>

<style type="text/css">
.top {
	height: 80px;
	border-bottom: 1px #95b8e7 solid;
	background-image: url(../images/top.jpg);
}

.button-tools {
	float: right;
	margin-right: 10px;
	margin-top: 40px;
}

.exit-system {
	float: right;
	margin-right: 10px;
	margin-left: 20px;
}
</style>

</head>
<body class="easyui-layout">
	<script type="text/javascript">
		if (window.top != window.self) {
			window.top.location = "./index.jsp";
		}
	</script>

	<div id="cc" class="easyui-layout"
		style="width: 100%; heith: 100%; min-height: 600px;"
		data-options="fit:true">


		<div data-options="region:'north',border:false"
			style="overflow: hidden; height: 80px;">
			<div class="top">
				<div class="button-tools">
					<div class="exit-system">
						<!-- 点击退出按钮，跳转到logout servlet中清除会话中的用户登录信息 -->
						<a id="exitSystem" target="_top" class="easyui-linkbutton"
							href="../logout" data-options="iconCls:'icon-no'">安全退出</a>
					</div>
					<div class="exit-system">
						<a id="modifyPassSystem" onclick="updatepass()"
							class="easyui-linkbutton"
							data-options="iconCls:'icon-large-clipart'">修改密码</a>
					</div>
					<div class="exit-system">
						<div class="curUserInfo">当前登录用户：${loginUser.userName}</div>
					</div>
				</div>
			</div>
		</div>


		<div data-options="region:'west',title:'管理菜单',split:true"
			style="width: 200px;">
			<div id="aa" class="easyui-accordion"
				data-options="fit:true,border:false">

				<div title="基础管理" data-options="iconCls:'icon-save',selected:true"
					style="overflow: auto; padding: 10px;">

					<a id="btn" href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true,"
						onclick="open_menu('用户管理','users/list.html')">用户管理</a><br> <a
						id="btn" href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('角色管理','role/list.html')">角色管理</a>
				</div>
				<div title="汽车销售管理" data-options="iconCls:'icon-reload'"
					style="padding: 10px;">

					<a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('预订管理','booking/index.jsp')">预订管理</a><br>
					<a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('客户管理','client/index.jsp')">客户管理</a><br> <a
						href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('评价管理','evaluation/index.jsp')">评价管理</a> <br>
					<a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('进库管理','in/index.jsp')">进库管理</a><br> <a
						href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('出库管理','out/index.jsp')">出库管理</a> <br> <a
						href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('供应商管理','provider/index.jsp')">供应商管理</a> <br>
					<a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true"
						onclick="open_menu('库存管理','store/index.jsp')">库存管理</a> <br>



				</div>
				<div title="系统管理" data-options="iconCls:'icon-reload'"
					style="padding: 10px;">
					<a href="javascript:void(0);" class="easyui-linkbutton"
						data-options="plain:true" onclick="updatepass()">修改密码</a> <br>
					<a href="../logout" class="easyui-linkbutton"
						data-options="plain:true">退出系统</a>
				</div>

			</div>
		</div>

		<div data-options="region:'center',border:false,plain:true">
			<div id="tt" class="easyui-tabs" data-options="fit:true"
				data-options="tools:'#tab-tools'">
				<div title="首页" style="text-align: center; font-size: 24px;">
					<p>欢迎来到汽车销售管理系统</p>
				</div>
			</div>
		</div>

		<div id="tab-tools">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				data-options="plain:true,iconCls:'icon-reload'" onclick="reload()"></a>
			<a href="javascript:void(0)" class="easyui-linkbutton"
				data-options="plain:true,iconCls:'icon-delete'" onclick="closecur()"></a>
		</div>

		<div id="mm" class="easyui-menu" style="width: 150px;">
			<div data-options="iconCls:'icon-reload'" id="refresh">刷新</div>
			<div class="menu-sep"></div>
			<div data-options="iconCls:'icon-delete0'" id="closecur">关闭当前</div>
			<div data-options="iconCls:'icon-delete0'" id="closeall">全部关闭</div>
			<div data-options="iconCls:'icon-delete0'" id="closeother">除此之外全部关闭</div>
			<div class="menu-sep"></div>
			<div data-options="iconCls:'icon-delete0'" id="closeright">当前页右侧全部关闭</div>
			<div data-options="iconCls:'icon-delete0'" id="closeleft">当前页左侧全部关闭</div>
		</div>


		<div data-options="region:'south',border:false,plain:true"
			style="height: 40px; text-align: center; font-size: 12px;">
			<p>版权所有,&copy;2016-2018</p>
		</div>
	</div>


	<div id="win" class="easyui-window" title="修改密码"
		style="width: 500px; height: 300px;" closed="true"
		data-options="collapsible:false,minimizable:false,resizable:false,maximizable:false"
		buttons="#updatepass_dlg-buttons">
		<form id="updatePasswordForm" style="padding: 10px 20px 10px 40px;">
			<p>
				旧密码: <input name="opassword" style="width: 260px;"
					class="easyui-passwordbox " prompt="请输入旧密码" required="true">
			</p>
			<p>
				新密码: <input id="npassword" name="npassword" style="width: 260px;"
					class="easyui-passwordbox " prompt="请输入新密码" required="true">
			</p>
			<p>
				新密码: <input id="npassword2" name="npassword2" style="width: 260px;"
					class="easyui-passwordbox " prompt="再一次输入新密码" required="true">
			</p>
			<div id="updatepass_dlg-buttons"
				style="text-align: center; margin-top: 50px;">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
					onclick="savePassword()">保存</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-cancel"
					style="margin-left: 50px;"
					onclick="javascript:$('#win').dialog('close')">取消</a>
			</div>
		</form>
	</div>



	<script type="text/javascript">
		function open_menu(titleName, menuUrl) {
			if ($("#tt").tabs("exists", titleName)) {
				$("#tt").tabs("select", titleName);
			} else {
				$('#tt').tabs('add', {
					title : titleName,
					href : menuUrl,
					closable : true
				});
			}
		}

		$(function() {
			bindContextMenu('#tt');
		});

		function updatepass() {
			$('#win').window('open');
		}
		function savePassword() {
			$('#updatePasswordForm').form('submit', {
				url : "../user/updatepassword",
				onSubmit : function() {
					var ret = $("npassword").val() == $("npassword2").val();
					if (ret) {
						return true;
					} else {
						$.messager.show({
							title : 'Error',
							msg : "两个新密码不相同"
						});
						return false
					}
				},
				success : function(result) {
					//收到服务器响应的json字符串后，调用这里的代码--回调函数，当浏览器收到服务器返回的数据后才执行
					var result = eval('(' + result + ')');
					if (!result.success) {
						//新增失败，使用消息框提示错误信息
						$.messager.show({
							title : 'Error',
							msg : result.errorMsg
						});
					} else {
						//修改密码成功，强制退出系统，要求重新登录
						window.location.href = "../logout";
					}
				}
			});
		}
	</script>

</body>
</html>